.class public Lcom/glympse/platform/SmsReceiver;
.super Landroid/content/BroadcastReceiver;
.source "SmsReceiver.java"


# static fields
.field private static final SMS_RECEIVED:Ljava/lang/String; = "android.provider.Telephony.SMS_RECEIVED"


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 22
    invoke-direct {p0}, Landroid/content/BroadcastReceiver;-><init>()V

    return-void
.end method

.method private getMessagesFromIntent(Landroid/content/Intent;)[Landroid/telephony/gsm/SmsMessage;
    .locals 6
    .parameter "oIntent"

    .prologue
    .line 100
    const/4 v0, 0x0

    check-cast v0, [Landroid/telephony/gsm/SmsMessage;

    .line 101
    .local v0, aoSmsMessages:[Landroid/telephony/gsm/SmsMessage;
    invoke-virtual {p1}, Landroid/content/Intent;->getExtras()Landroid/os/Bundle;

    move-result-object v3

    .line 102
    .local v3, oBundle:Landroid/os/Bundle;
    if-eqz v3, :cond_0

    .line 106
    :try_start_0
    const-string v5, "pdus"

    invoke-virtual {v3, v5}, Landroid/os/Bundle;->get(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v4

    check-cast v4, [Ljava/lang/Object;

    .line 107
    .local v4, pdus:[Ljava/lang/Object;
    array-length v5, v4

    new-array v0, v5, [Landroid/telephony/gsm/SmsMessage;

    .line 108
    const/4 v2, 0x0

    .end local p0
    .local v2, nMessage:I
    :goto_0
    array-length v5, v4

    if-lt v2, v5, :cond_1

    .line 118
    .end local v2           #nMessage:I
    .end local v4           #pdus:[Ljava/lang/Object;
    :cond_0
    :goto_1
    return-object v0

    .line 110
    .restart local v2       #nMessage:I
    .restart local v4       #pdus:[Ljava/lang/Object;
    :cond_1
    aget-object p0, v4, v2

    check-cast p0, [B

    invoke-static {p0}, Landroid/telephony/gsm/SmsMessage;->createFromPdu([B)Landroid/telephony/gsm/SmsMessage;

    move-result-object v5

    aput-object v5, v0, v2
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 108
    add-int/lit8 v2, v2, 0x1

    goto :goto_0

    .line 113
    .end local v2           #nMessage:I
    .end local v4           #pdus:[Ljava/lang/Object;
    :catch_0
    move-exception v5

    move-object v1, v5

    .line 115
    .local v1, e:Ljava/lang/Exception;
    invoke-static {v1}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V

    goto :goto_1
.end method


# virtual methods
.method public onReceive(Landroid/content/Context;Landroid/content/Intent;)V
    .locals 13
    .parameter "oContext"
    .parameter "oIntent"

    .prologue
    .line 29
    const-string v9, "SMSReceiver::onReceive"

    invoke-static {v9}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/String;)V

    .line 35
    :try_start_0
    invoke-static {}, Lcom/glympse/platform/Platform;->instance()Lcom/glympse/platform/Platform;

    move-result-object v9

    if-eqz v9, :cond_0

    invoke-static {}, Lcom/glympse/platform/Platform;->instance()Lcom/glympse/platform/Platform;

    move-result-object v9

    iget-object v9, v9, Lcom/glympse/platform/Platform;->m_oServerPost:Lcom/glympse/platform/common/ServerPost;

    if-eqz v9, :cond_0

    .line 38
    if-eqz p2, :cond_0

    invoke-virtual {p2}, Landroid/content/Intent;->getAction()Ljava/lang/String;

    move-result-object v9

    const-string v10, "android.provider.Telephony.SMS_RECEIVED"

    invoke-virtual {v9, v10}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v9

    if-eqz v9, :cond_0

    .line 41
    invoke-direct {p0, p2}, Lcom/glympse/platform/SmsReceiver;->getMessagesFromIntent(Landroid/content/Intent;)[Landroid/telephony/gsm/SmsMessage;

    move-result-object v0

    .line 42
    .local v0, aoSmsMessages:[Landroid/telephony/gsm/SmsMessage;
    if-eqz v0, :cond_0

    .line 44
    new-instance v6, Lcom/glympse/platform/GVector$Longs;

    invoke-direct {v6}, Lcom/glympse/platform/GVector$Longs;-><init>()V

    .line 45
    .local v6, listTicketIds:Lcom/glympse/platform/GVector$Longs;,"Lcom/glympse/platform/GVector$Longs;"
    const-wide/16 v2, 0x0

    .line 48
    .local v2, lLatestTime:J
    array-length v9, v0

    const/4 v10, 0x0

    :goto_0
    if-lt v10, v9, :cond_1

    .line 85
    invoke-static {}, Lcom/glympse/platform/Platform;->instance()Lcom/glympse/platform/Platform;

    move-result-object v9

    iget-object v9, v9, Lcom/glympse/platform/Platform;->m_oServerPost:Lcom/glympse/platform/common/ServerPost;

    invoke-virtual {v9, v6, v2, v3}, Lcom/glympse/platform/common/ServerPost;->AddReceivedSmsTickets(Lcom/glympse/platform/GVector$Longs;J)Z

    .line 86
    invoke-static {}, Lcom/glympse/platform/Platform;->instance()Lcom/glympse/platform/Platform;

    move-result-object v9

    iget-object v9, v9, Lcom/glympse/platform/Platform;->m_oServerPost:Lcom/glympse/platform/common/ServerPost;

    invoke-virtual {v9}, Lcom/glympse/platform/common/ServerPost;->PostNow()V

    .line 95
    .end local v0           #aoSmsMessages:[Landroid/telephony/gsm/SmsMessage;
    .end local v2           #lLatestTime:J
    .end local v6           #listTicketIds:Lcom/glympse/platform/GVector$Longs;,"Lcom/glympse/platform/GVector$Longs;"
    :cond_0
    :goto_1
    return-void

    .line 48
    .restart local v0       #aoSmsMessages:[Landroid/telephony/gsm/SmsMessage;
    .restart local v2       #lLatestTime:J
    .restart local v6       #listTicketIds:Lcom/glympse/platform/GVector$Longs;,"Lcom/glympse/platform/GVector$Longs;"
    :cond_1
    aget-object v7, v0, v10
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_1

    .line 50
    .local v7, oSmsMessage:Landroid/telephony/gsm/SmsMessage;
    if-eqz v7, :cond_3

    .line 61
    :try_start_1
    invoke-virtual {v7}, Landroid/telephony/gsm/SmsMessage;->getTimestampMillis()J

    move-result-wide v4

    .line 64
    .local v4, lTime:J
    cmp-long v11, v4, v2

    if-lez v11, :cond_2

    .line 66
    move-wide v2, v4

    .line 70
    :cond_2
    new-instance v8, Lcom/glympse/platform/common/UrlParser;

    invoke-direct {v8}, Lcom/glympse/platform/common/UrlParser;-><init>()V

    .line 71
    .local v8, oUrlParser:Lcom/glympse/platform/common/UrlParser;
    invoke-virtual {v7}, Landroid/telephony/gsm/SmsMessage;->getDisplayMessageBody()Ljava/lang/String;

    move-result-object v11

    const/4 v12, 0x1

    invoke-virtual {v8, v11, v12}, Lcom/glympse/platform/common/UrlParser;->ParseUrls(Ljava/lang/String;Z)Z

    .line 72
    iget-object v11, v8, Lcom/glympse/platform/common/UrlParser;->m_listTicketIds:Lcom/glympse/platform/GVector$Longs;

    if-eqz v11, :cond_3

    .line 74
    iget-object v11, v8, Lcom/glympse/platform/common/UrlParser;->m_listTicketIds:Lcom/glympse/platform/GVector$Longs;

    invoke-virtual {v6, v11}, Lcom/glympse/platform/GVector$Longs;->addAll(Ljava/util/Collection;)Z
    :try_end_1
    .catch Ljava/lang/Exception; {:try_start_1 .. :try_end_1} :catch_0

    .line 48
    .end local v4           #lTime:J
    .end local v8           #oUrlParser:Lcom/glympse/platform/common/UrlParser;
    :cond_3
    :goto_2
    add-int/lit8 v10, v10, 0x1

    goto :goto_0

    .line 77
    :catch_0
    move-exception v11

    move-object v1, v11

    .line 79
    .local v1, e:Ljava/lang/Exception;
    :try_start_2
    invoke-static {v1}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V
    :try_end_2
    .catch Ljava/lang/Exception; {:try_start_2 .. :try_end_2} :catch_1

    goto :goto_2

    .line 91
    .end local v0           #aoSmsMessages:[Landroid/telephony/gsm/SmsMessage;
    .end local v1           #e:Ljava/lang/Exception;
    .end local v2           #lLatestTime:J
    .end local v6           #listTicketIds:Lcom/glympse/platform/GVector$Longs;,"Lcom/glympse/platform/GVector$Longs;"
    .end local v7           #oSmsMessage:Landroid/telephony/gsm/SmsMessage;
    :catch_1
    move-exception v9

    move-object v1, v9

    .line 93
    .restart local v1       #e:Ljava/lang/Exception;
    invoke-static {v1}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V

    goto :goto_1
.end method
